<?php
error_reporting(0);
$isadmin=1;
$isadmin=1;
include_once '../comm/config.php';
include_once '../comm/checkpostandget.php';
include_once 'include/page.class.php';
include_once 'check.php';
$tao_status=include('../comm/tao_status.php');
$keyword=$_GET['keyword']; 
$qr=$_GET['qr']; 
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=10;
$page2=($page-1)*$pagesize;
$subsql="";
if($qr=="1")
{
	$subsql=" and outer_code<>'' ";
}
if($qr=="0")
{
	$subsql=" and outer_code=''";
}

$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
	die(ERR_DB);
}
else
{
	mysql_query("set names utf8");
	$sql="select * from ".$BIAOTOU."tradelist where (trade_id like '%".$keyword."%' or item_title like '%".$keyword."%') ".$subsql;
	mysql_select_db($dbname);
	$rs = mysql_query($sql);
	$total = mysql_num_rows($rs);	
	
	$sql="select * from ".$BIAOTOU."tradelist where (trade_id like '%".$keyword."%' or item_title like '%".$keyword."%' )".$subsql." order by pay_time desc limit $page2,$pagesize";
	$rs = mysql_query($sql);
}	
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<script src="../js/jquery.colorbox.js"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
-->
</style>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td width="358" height="30" align="left" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="images/arrow.gif" width="16" height="22" align="absmiddle" /> 交易管理 [ <a href="daoru.php" class="link3">手动获取订单</a> ] </strong></td>
              <form id="form1" name="form1" method="get" action="">
              <td width="479" align="left" bgcolor="E9F2FB" class="bigtext">交易号或商品名
                  <input type="text" class="button3" name="keyword" />
                  <select name="qr">
                    <option>全部</option>
                    <option value="1" <?php if ($qr=="1") echo "selected";?>>已经确认</option>
                    <option value="0" <?php if ($qr=="0") echo "selected";?>>还未确认</option>
                  </select>

                <input type="submit" name="Submit" value="查找" />
                </td></form>
              <td width="130" height="30" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $total;?></b> 条记录&nbsp;&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" border=1 cellpadding=0 cellspacing=0
style="border-collapse: collapse" bordercolor="#dddddd">
                    <tr>
                      <td width="11%" align=center height="30" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;淘宝交易号</strong></td>
                      <td width="28%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>商品名称</strong></td>
                      <td width="5%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;单价</strong></td>
					  <td width="6%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;数量</strong></td>
                      <td width="6%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;总佣金</strong></td>
                      <td width="6%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;返现额</strong></td>                      
                      <td width="8%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;交易时间</strong></td>
                      <td width="9%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;交易会员</strong></td>
                      <td width="" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;订单状态</strong></td>
                      <td width="10%" align="center" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;执行操作</strong></td>
                    </tr>
                    <?php
					while ($row = mysql_fetch_array($rs))
					{
						if($row["outer_code"]!=""){
							$jyuser="";
							$sql="select ddusername from ".$BIAOTOU."user where Id=".$row["outer_code"]."";
							mysql_query("set names utf8");
							mysql_select_db($dbname);
							$rs2 = mysql_query($sql);
							while ($row2 = mysql_fetch_array($rs2))
							{
								$jyuser=$row2["ddusername"]; }
						}
						else
						{
							$jyuser="";
						}
						echo "<tr>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;".$row["trade_id"]."</td>";
                      	echo "<td align=center height=30 class=bigtext><div style='width:250px;overflow:hidden; height:30px; line-height:30px;'>".$row["item_title"]."</div></td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["pay_price"]."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["item_num"]."</td>";
						echo "<td align=center class=bigtext >&nbsp;".round($row["commission"],2)."</td>";
						echo "<td align=center class=bigtext >&nbsp;".round($row["fxje"],2)."</td>";						
						echo "<td align=center class=bigtext>&nbsp;".date("Y-m-d",strtotime($row["pay_time"]))."</td>";
						echo "<td align=center class=bigtext>&nbsp;".$jyuser."</td>";
						echo "<td align=center value='".$row["trade_id"]."'>&nbsp;".$tao_status[$row["checked"]]."</td>";
						echo "<td align=center class=bigtext>&nbsp;<a href=fanxiantrade.php?id=".$row["Id"]." class=link4>返现</a> | <a href=deltrade.php?id=".$row["Id"]." class=link4>删除</a></td>";
						echo "</tr>";
					}
					?></table>
<div class="yahoo2" style=" margin-top:30px;"><?php 
				pageft($total,$pagesize,1,1,0,10,"tradelist.php?keyword=".urlencode($keyword)."&qr=".$_GET['qr']);
				echo $pagenav;?></div>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close($link);?>
